package com.example.synatx.optional;

import java.util.Optional;

public class OptionalTest {

    public void test01(){
        //声明一个空的optional
        Optional<Car> car = Optional.empty();
        //依据一个非空值创建Optional
        Car car1 = new Car();
        Optional<Car> optCar = Optional.of(car1);
        //可接收null的optional
        Optional<Car> optcar1 = Optional.ofNullable(car1);
    }
}
